<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

class DevController extends Controller
{
    public function importVueComponent()
    {

    }

    public function getPermission(): array
    {
        $routes = [];
        foreach (Route::getRoutes()->getRoutes() as $route) {
            $an = $route->getActionName();
            if (str_contains($an, 'App\Http\Controllers') &&
                !str_contains($an, 'AuthController') &&
                !str_contains($an, 'DevController')) {
                $method = $route->methods[0];
                $uri = $route->uri;
                $slug = md5($method . $uri);
                $name = $route->getName() ?: '无';
                $routes[] = compact('method', 'uri', 'slug', 'name');
            }
        }
        return $this->success(data: $routes);
    }

    public function importPermission()
    {

    }
}
